Graphs model relationships in familiar systems like social networks.
- Nodes represent people and edges represent friendships or follows. Many common questions reduce to simple graph queries: “Are A and B connected?”, “Who are A’s neighbors?”, or “What is A’s degree?”.
- This simple model allows us to reason about different relationship types, such as undirected vs. directed (a mutual friendship vs. a one-way follow) and weighted edges (representing the strength of an interaction).
- The key takeaway is that graphs model relationships directly, and the choice of how we store that graph in a data structure has a major impact on how quickly we can answer questions about those relationships.